//
//  ViewController.m
//  LayoutVFL
//
//  Created by hyl on 16/5/19.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    redView.translatesAutoresizingMaskIntoConstraints=NO;
    [self.view addSubview:redView];
    
    UIView *blueView=[[UIView alloc]init];
    blueView.backgroundColor=[UIColor blueColor];
    blueView.translatesAutoresizingMaskIntoConstraints=NO;
    [self.view addSubview:blueView];
    
    NSString *Str=@"H:|-20-[redView]-20-[blueView(==redView)]-20-|";
    NSArray *hConstraints=[NSLayoutConstraint constraintsWithVisualFormat:Str options:NSLayoutFormatAlignAllTop|NSLayoutFormatAlignAllBottom metrics:nil views:NSDictionaryOfVariableBindings(redView,blueView)];
    [self.view addConstraints:hConstraints];
    
    NSString *Str2=@"V:|-30-[redView(==50)]";
    NSArray *vConstraints=[NSLayoutConstraint constraintsWithVisualFormat:Str2 options:kNilOptions metrics:nil views:NSDictionaryOfVariableBindings(redView)];
    [self.view addConstraints:vConstraints];
    
}


@end
